Skip to content

perf: optimisation for date_part with seconds#23444

Open
theirix wants to merge 1 commit into
apache:mainfrom
theirix:perf-date_part-seconds
Open

perf: optimisation for date_part with seconds#23444
theirix wants to merge 1 commit into
apache:mainfrom
theirix:perf-date_part-seconds

Conversation

@theirix

@theirix theirix commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Benches were added recently in #23350 . Improve and measure some optimisations.

What changes are included in this PR?

  • Improve performance for seconds_ns and seconds_as_i32. A pretty rare code path.

Are these changes tested?

  • Tests are passing
  • Bench-measured perf is improving

Are there any user-facing changes?

@github-actions github-actions Bot added the functions Changes to functions implementation label Jul 10, 2026
@theirix theirix marked this pull request as ready for review July 10, 2026 10:47
@comphead

Copy link
Copy Markdown
Contributor

run benchmark date_part

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4939575141-964-64q5l 6.12.85+ #1 SMP Mon May 11 08:17:35 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing perf-date_part-seconds (a68f33a) to 1e77af8 (merge-base) diff using: date_part
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                  HEAD                                   perf-date_part-seconds
-----                                  ----                                   ----------------------
date_part_day_date32_1000              1.01      6.3±0.01µs        ? ?/sec    1.00      6.3±0.01µs        ? ?/sec
date_part_day_date64_1000              1.00     10.7±0.01µs        ? ?/sec    1.00     10.7±0.01µs        ? ?/sec
date_part_day_ms_1000                  1.00     10.7±0.00µs        ? ?/sec    1.01     10.8±0.02µs        ? ?/sec
date_part_day_ns_1000                  1.02     10.4±0.01µs        ? ?/sec    1.00     10.1±0.01µs        ? ?/sec
date_part_day_s_1000                   1.01      8.1±0.01µs        ? ?/sec    1.00      8.0±0.01µs        ? ?/sec
date_part_day_us_1000                  1.02     10.5±0.01µs        ? ?/sec    1.00     10.3±0.01µs        ? ?/sec
date_part_dow_timestamp_ns_1000        1.00     11.7±0.01µs        ? ?/sec    1.00     11.7±0.01µs        ? ?/sec
date_part_doy_timestamp_ns_1000        1.00      9.5±0.01µs        ? ?/sec    1.00      9.4±0.01µs        ? ?/sec
date_part_epoch_date32_1000            1.00    527.9±2.87ns        ? ?/sec    1.01    531.7±2.34ns        ? ?/sec
date_part_epoch_date64_1000            1.00   1185.4±0.78ns        ? ?/sec    1.00   1185.7±1.29ns        ? ?/sec
date_part_epoch_duration_ns_1000       1.00      6.8±0.06µs        ? ?/sec    1.00      6.7±0.05µs        ? ?/sec
date_part_epoch_interval_dt_1000       1.00   1199.5±1.16ns        ? ?/sec    1.00   1198.7±1.76ns        ? ?/sec
date_part_epoch_interval_mdn_1000      1.00   1281.4±1.36ns        ? ?/sec    1.00   1280.6±3.46ns        ? ?/sec
date_part_epoch_interval_ym_1000       1.00    587.4±1.46ns        ? ?/sec    1.00    585.3±1.47ns        ? ?/sec
date_part_epoch_ms_1000                1.00   1190.5±1.70ns        ? ?/sec    1.00   1193.2±3.43ns        ? ?/sec
date_part_epoch_ns_1000                1.00   1188.9±1.01ns        ? ?/sec    1.01   1195.9±3.48ns        ? ?/sec
date_part_epoch_s_1000                 1.00    425.7±2.75ns        ? ?/sec    1.00    425.2±3.73ns        ? ?/sec
date_part_epoch_time32_ms_1000         1.00   1187.5±1.56ns        ? ?/sec    1.00   1187.6±2.04ns        ? ?/sec
date_part_epoch_time32_s_1000          1.00    462.2±2.98ns        ? ?/sec    1.00    463.4±3.12ns        ? ?/sec
date_part_epoch_time64_ns_1000         1.01   1191.6±1.01ns        ? ?/sec    1.00   1184.2±2.11ns        ? ?/sec
date_part_epoch_time64_us_1000         1.01   1192.2±1.81ns        ? ?/sec    1.00   1184.8±1.93ns        ? ?/sec
date_part_epoch_us_1000                1.00   1191.7±0.92ns        ? ?/sec    1.00   1194.8±3.74ns        ? ?/sec
date_part_hour_ms_1000                 1.00     10.2±0.01µs        ? ?/sec    1.00     10.2±0.04µs        ? ?/sec
date_part_hour_ns_1000                 1.00      9.7±0.01µs        ? ?/sec    1.00      9.7±0.01µs        ? ?/sec
date_part_hour_s_1000                  1.00      7.6±0.00µs        ? ?/sec    1.00      7.6±0.01µs        ? ?/sec
date_part_hour_us_1000                 1.01      9.9±0.06µs        ? ?/sec    1.00      9.8±0.01µs        ? ?/sec
date_part_isodow_timestamp_ns_1000     1.00     11.2±0.01µs        ? ?/sec    1.00     11.2±0.01µs        ? ?/sec
date_part_isoyear_timestamp_ns_1000    1.00     14.4±0.01µs        ? ?/sec    1.00     14.4±0.01µs        ? ?/sec
date_part_microsecond_date32_1000      9.47      3.0±0.00µs        ? ?/sec    1.00    315.7±2.36ns        ? ?/sec
date_part_microsecond_date64_1000      69.93    22.0±0.01µs        ? ?/sec    1.00    314.1±1.29ns        ? ?/sec
date_part_microsecond_ms_1000          1.00     23.9±0.02µs        ? ?/sec    1.00     24.0±0.02µs        ? ?/sec
date_part_microsecond_ns_1000          1.00     22.8±0.03µs        ? ?/sec    1.00     22.8±0.02µs        ? ?/sec
date_part_microsecond_s_1000           1.00     10.5±0.01µs        ? ?/sec    1.00     10.5±0.02µs        ? ?/sec
date_part_microsecond_us_1000          1.01     23.3±0.07µs        ? ?/sec    1.00     23.2±0.02µs        ? ?/sec
date_part_millisecond_date32_1000      9.45      3.0±0.00µs        ? ?/sec    1.00    319.0±2.10ns        ? ?/sec
date_part_millisecond_date64_1000      69.34    22.1±0.02µs        ? ?/sec    1.00    319.3±2.52ns        ? ?/sec
date_part_millisecond_ms_1000          1.01     23.0±0.05µs        ? ?/sec    1.00     22.9±0.01µs        ? ?/sec
date_part_millisecond_ns_1000          1.00     22.1±0.02µs        ? ?/sec    1.00     22.0±0.04µs        ? ?/sec
date_part_millisecond_s_1000           1.00     10.5±0.01µs        ? ?/sec    1.00     10.5±0.01µs        ? ?/sec
date_part_millisecond_us_1000          1.00     22.4±0.02µs        ? ?/sec    1.00     22.4±0.02µs        ? ?/sec
date_part_minute_ms_1000               1.00     10.9±0.01µs        ? ?/sec    1.00     10.8±0.01µs        ? ?/sec
date_part_minute_ns_1000               1.00     10.7±0.01µs        ? ?/sec    1.00     10.6±0.01µs        ? ?/sec
date_part_minute_s_1000                1.01      8.3±0.01µs        ? ?/sec    1.00      8.2±0.01µs        ? ?/sec
date_part_minute_us_1000               1.00     10.7±0.01µs        ? ?/sec    1.01     10.8±0.01µs        ? ?/sec
date_part_month_date32_1000            1.00      6.1±0.00µs        ? ?/sec    1.01      6.2±0.03µs        ? ?/sec
date_part_month_date64_1000            1.00     10.5±0.01µs        ? ?/sec    1.01     10.6±0.02µs        ? ?/sec
date_part_month_ms_1000                1.00     10.6±0.01µs        ? ?/sec    1.00     10.6±0.01µs        ? ?/sec
date_part_month_ns_1000                1.00     10.0±0.01µs        ? ?/sec    1.00      9.9±0.01µs        ? ?/sec
date_part_month_s_1000                 1.00      7.9±0.02µs        ? ?/sec    1.00      8.0±0.05µs        ? ?/sec
date_part_month_us_1000                1.00     10.1±0.01µs        ? ?/sec    1.00     10.1±0.02µs        ? ?/sec
date_part_nanosecond_date32_1000       2.33    792.9±1.71ns        ? ?/sec    1.00    339.8±2.31ns        ? ?/sec
date_part_nanosecond_date64_1000       58.58    19.8±0.02µs        ? ?/sec    1.00    338.2±1.39ns        ? ?/sec
date_part_nanosecond_ms_1000           1.00     20.3±0.02µs        ? ?/sec    1.00     20.4±0.02µs        ? ?/sec
date_part_nanosecond_ns_1000           1.00     19.5±0.02µs        ? ?/sec    1.00     19.5±0.02µs        ? ?/sec
date_part_nanosecond_s_1000            1.00      8.2±0.01µs        ? ?/sec    1.00      8.3±0.01µs        ? ?/sec
date_part_nanosecond_us_1000           1.00     19.8±0.02µs        ? ?/sec    1.00     19.9±0.04µs        ? ?/sec
date_part_quarter_timestamp_ns_1000    1.00     11.1±0.01µs        ? ?/sec    1.00     11.0±0.01µs        ? ?/sec
date_part_second_date32_1000           9.10      3.0±0.00µs        ? ?/sec    1.00    330.5±1.92ns        ? ?/sec
date_part_second_date64_1000           2.20     22.0±0.01µs        ? ?/sec    1.00     10.0±0.01µs        ? ?/sec
date_part_second_ms_1000               2.17     22.5±0.02µs        ? ?/sec    1.00     10.4±0.01µs        ? ?/sec
date_part_second_ns_1000               2.14     21.6±0.02µs        ? ?/sec    1.00     10.1±0.01µs        ? ?/sec
date_part_second_s_1000                1.35     10.5±0.01µs        ? ?/sec    1.00      7.7±0.00µs        ? ?/sec
date_part_second_us_1000               2.17     22.3±0.26µs        ? ?/sec    1.00     10.3±0.01µs        ? ?/sec
date_part_week_date32_1000             1.00      9.9±0.00µs        ? ?/sec    1.00      9.9±0.01µs        ? ?/sec
date_part_week_date64_1000             1.00     14.5±0.02µs        ? ?/sec    1.02     14.8±0.01µs        ? ?/sec
date_part_week_ms_1000                 1.00     14.8±0.01µs        ? ?/sec    1.00     14.7±0.02µs        ? ?/sec
date_part_week_ns_1000                 1.00     14.2±0.01µs        ? ?/sec    1.01     14.3±0.01µs        ? ?/sec
date_part_week_s_1000                  1.00     11.9±0.01µs        ? ?/sec    1.01     12.0±0.01µs        ? ?/sec
date_part_week_us_1000                 1.00     14.3±0.02µs        ? ?/sec    1.01     14.4±0.01µs        ? ?/sec
date_part_year_date32_1000             1.01      5.7±0.01µs        ? ?/sec    1.00      5.6±0.01µs        ? ?/sec
date_part_year_date64_1000             1.00      9.8±0.01µs        ? ?/sec    1.01      9.8±0.02µs        ? ?/sec
date_part_year_ms_1000                 1.00      9.9±0.01µs        ? ?/sec    1.01     10.0±0.04µs        ? ?/sec
date_part_year_ns_1000                 1.00      9.4±0.02µs        ? ?/sec    1.00      9.4±0.01µs        ? ?/sec
date_part_year_s_1000                  1.00      7.2±0.00µs        ? ?/sec    1.00      7.2±0.02µs        ? ?/sec
date_part_year_us_1000                 1.00      9.6±0.02µs        ? ?/sec    1.01      9.7±0.02µs        ? ?/sec

Resource Usage

date_part — base (merge-base)

Metric Value
Wall time 1010.2s
Peak memory 33.9 MiB
Avg memory 23.6 MiB
CPU user 944.8s
CPU sys 0.7s
Peak spill 0 B

date_part — branch

Metric Value
Wall time 1000.2s
Peak memory 35.9 MiB
Avg memory 25.6 MiB
CPU user 946.6s
CPU sys 0.8s
Peak spill 0 B

File an issue against this benchmark runner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: date_part UDF optimisations

3 participants